package com.micangcaihang.micang.mvp.task.ui;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;

import com.micangcaihang.common.base.fragment.BaseFragment;
import com.micangcaihang.micang.R;
import com.micangcaihang.micang.adapter.AccessoryInfoAdapter;
import com.micangcaihang.micang.databinding.FragmentTaskAccessoryInfoThreeBinding;
import com.micangcaihang.micang.entity.TaskAccessoryInfoEntity;
import com.micangcaihang.micang.http.request.TaskAccessoryInfoRequest;
import com.micangcaihang.micang.mvp.task.contract.TaskAccessoryInfoThreeContract;
import com.micangcaihang.micang.mvp.task.presenter.TaskAccessoryInfoThreePresenter;

import java.util.ArrayList;
import java.util.List;

/**
 * <pre>
 *     author : Fandy
 *     e-mail : fandayongfly@gmail.com
 *     time   : 2017/07/24
 *     update : 2017/07/24
 *     desc   : 附件信息3
 *     version: 1.0
 * </pre>
 */

public class TaskAccessoryInfoThreeFragment extends BaseFragment<TaskAccessoryInfoThreePresenter, FragmentTaskAccessoryInfoThreeBinding> implements TaskAccessoryInfoThreeContract.View {
    private AccessoryInfoAdapter mAdapter;
    private String id;
    private TaskAccessoryInfoRequest mRequest;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        id = getArguments().getString("id");
    }

    public static TaskAccessoryInfoThreeFragment newInstance(String id) {
        Bundle args = new Bundle();
        TaskAccessoryInfoThreeFragment fragment = new TaskAccessoryInfoThreeFragment();
        args.putString("id", id);
        fragment.setArguments(args);
        return fragment;
    }

    /**
     * 获取资源文件布局
     *
     * @return 资源布局文件layout
     */
    @Override
    protected int getLayoutId() {
        return R.layout.fragment_task_accessory_info_three;
    }

    @Override
    public void initView(View rootView) {
        super.initView(rootView);
        mViewBinding.recyclerView.setLayoutManager(new LinearLayoutManager(_mActivity));
    }

    @Override
    public void initPresenter() {
        super.initPresenter();
        mPresenter.setId(id);
        mPresenter.setFile_type("1");
    }

    @Override
    protected void initData() {
        super.initData();
        mRequest = new TaskAccessoryInfoRequest();
        mAdapter = new AccessoryInfoAdapter(_mActivity,new ArrayList<>());
        mViewBinding.recyclerView.setAdapter(mAdapter);
    }

    /**
     * 初始化按钮监听
     */
    @Override
    protected void initListener() {
        mViewBinding.setClickHandler(new ClickHandler());
    }

    /**
     * 返回附件信息3信息
     *
     * @param data
     */
    @Override
    public void returnAccessoryInfoData(List<TaskAccessoryInfoEntity> data) {

    }

    public class ClickHandler {
        public void onSave(View view) {

        }
    }
}
